/*
 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "kh_sle_c_interface_test_entry.h"

void KhSleCInterfaceTestEntry(void)
{
    SLE_UT_LOG("_KhSleCInterfaceTestEntry start");
    KhSleHostTestEntry();
    SleErrorCode ret = InitSleHostService();
    SLE_UT_CHECK_AND_RETURN_LOG(ret == SLE_NO_ERROR, "InitSleHostService failed");
    ret = SleEnable();
    SLE_UT_CHECK_AND_RETURN_LOG(ret == SLE_NO_ERROR || ret == SLE_ERR_ENABLE_SUCCESS_WHEN_ENABLED, "SleEnable failed");
    KhSleAnnounceTestEntry();
    KhSleSeekTestEntry();
    KhSleConnectTestEntry();
    ret = InitSleConnectService();
    SLE_UT_CHECK_AND_RETURN_LOG(ret == SLE_NO_ERROR, "InitSleConnectService failed");
    SleDeviceAddress remoteAddr = {
        .addrType = SLE_PUBLIC_ADDRESS_TYPE,
        .addr = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}
    };
    ret = SleConnect(&remoteAddr);
    SLE_UT_CHECK_AND_RETURN_LOG(ret == SLE_NO_ERROR, "SleConnect failed");
    KhSleSsapcTestEntry();
    KhSleSsapsTestEntry();
    ret = SleDisconnect(&remoteAddr);
    ret = SleDisable();
    SLE_UT_CHECK_AND_RETURN_LOG(ret == SLE_NO_ERROR || ret == SLE_ERR_DISABLE_SUCCESS_WHEN_DISABLED, "SleDisable failed");
    ret = DeinitSleHostService();
    SLE_UT_CHECK_AND_RETURN_LOG(ret == SLE_NO_ERROR, "DeinitSleHostService failed");
    SLE_UT_LOG("_KhSleCInterfaceTestEntry end");
}